﻿///////////////////////////////////////////////////////////////
// This is generated code. 
//////////////////////////////////////////////////////////////
// Code is generated using LLBLGen Pro version: 3.5
// Code is generated on: Monday, December 17, 2012 11:21:48 AM
// Code is generated using templates: SD.TemplateBindings.SharedTemplates.NET20
// Templates vendor: Solutions Design.
// Templates version: 
//////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using WHMS.EntityClasses;
using WHMS.HelperClasses;
using WHMS.RelationClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;

namespace WHMS.FactoryClasses
{
	
	// __LLBLGENPRO_USER_CODE_REGION_START AdditionalNamespaces
	// __LLBLGENPRO_USER_CODE_REGION_END
	
	/// <summary>general base class for the generated factories</summary>
	[Serializable]
	public partial class EntityFactoryBase2<TEntity> : EntityFactoryCore2
		where TEntity : EntityBase2, IEntity2
	{
		private readonly WHMS.EntityType _typeOfEntity;
		private readonly bool _isInHierarchy;
		
		/// <summary>CTor</summary>
		/// <param name="entityName">Name of the entity.</param>
		/// <param name="typeOfEntity">The type of entity.</param>
		/// <param name="isInHierarchy">If true, the entity of this factory is in an inheritance hierarchy, false otherwise</param>
		public EntityFactoryBase2(string entityName, WHMS.EntityType typeOfEntity, bool isInHierarchy) : base(entityName)
		{
			_typeOfEntity = typeOfEntity;
			_isInHierarchy = isInHierarchy;
		}
		
		/// <summary>Creates, using the generated EntityFieldsFactory, the IEntityFields2 object for the entity to create.</summary>
		/// <returns>Empty IEntityFields2 object.</returns>
		public override IEntityFields2 CreateFields()
		{
			return EntityFieldsFactory.CreateEntityFieldsObject(_typeOfEntity);
		}
		
		/// <summary>Creates a new entity instance using the GeneralEntityFactory in the generated code, using the passed in entitytype value</summary>
		/// <param name="entityTypeValue">The entity type value of the entity to create an instance for.</param>
		/// <returns>new IEntity instance</returns>
		public override IEntity2 CreateEntityFromEntityTypeValue(int entityTypeValue)
		{
			return GeneralEntityFactory.Create((WHMS.EntityType)entityTypeValue);
		}

		/// <summary>Creates the relations collection to the entity to join all targets so this entity can be fetched. </summary>
		/// <param name="objectAlias">The object alias to use for the elements in the relations.</param>
		/// <returns>null if the entity isn't in a hierarchy of type TargetPerEntity, otherwise the relations collection needed to join all targets together to fetch all subtypes of this entity and this entity itself</returns>
		public override IRelationCollection CreateHierarchyRelations(string objectAlias) 
		{
			return InheritanceInfoProviderSingleton.GetInstance().GetHierarchyRelations(this.ForEntityName, objectAlias);
		}

		/// <summary>This method retrieves, using the InheritanceInfoprovider, the factory for the entity represented by the values passed in.</summary>
		/// <param name="fieldValues">Field values read from the db, to determine which factory to return, based on the field values passed in.</param>
		/// <param name="entityFieldStartIndexesPerEntity">indexes into values where per entity type their own fields start.</param>
		/// <returns>the factory for the entity which is represented by the values passed in.</returns>
		public override IEntityFactory2 GetEntityFactory(object[] fieldValues, Dictionary<string, int> entityFieldStartIndexesPerEntity) 
		{
			IEntityFactory2 toReturn = (IEntityFactory2)InheritanceInfoProviderSingleton.GetInstance().GetEntityFactory(this.ForEntityName, fieldValues, entityFieldStartIndexesPerEntity);
			if(toReturn == null)
			{
				toReturn = this;
			}
			return toReturn;
		}
		
		/// <summary>Gets a predicateexpression which filters on the entity with type belonging to this factory.</summary>
		/// <param name="negate">Flag to produce a NOT filter, (true), or a normal filter (false). </param>
		/// <param name="objectAlias">The object alias to use for the predicate(s).</param>
		/// <returns>ready to use predicateexpression, or an empty predicate expression if the belonging entity isn't a hierarchical type.</returns>
		public override IPredicateExpression GetEntityTypeFilter(bool negate, string objectAlias) 
		{
			return InheritanceInfoProviderSingleton.GetInstance().GetEntityTypeFilter(this.ForEntityName, objectAlias, negate);
		}
						
		/// <summary>Creates a new generic EntityCollection(Of T) for the entity which this factory belongs to.</summary>
		/// <returns>ready to use generic EntityCollection(Of T) with this factory set as the factory</returns>
		public override IEntityCollection2 CreateEntityCollection()
		{
			return new EntityCollection<TEntity>(this);
		}
		
		/// <summary>Creates the hierarchy fields for the entity to which this factory belongs.</summary>
		/// <returns>IEntityFields2 object with the fields of all the entities in teh hierarchy of this entity or the fields of this entity if the entity isn't in a hierarchy.</returns>
		public override IEntityFields2 CreateHierarchyFields() 
		{
			return _isInHierarchy ? new EntityFields2(InheritanceInfoProviderSingleton.GetInstance().GetHierarchyFields(this.ForEntityName), InheritanceInfoProviderSingleton.GetInstance(), null) : base.CreateHierarchyFields();
		}
	}

	/// <summary>Factory to create new, empty ContractorEntity objects.</summary>
	[Serializable]
	public partial class ContractorEntityFactory : EntityFactoryBase2<ContractorEntity> {
		/// <summary>CTor</summary>
		public ContractorEntityFactory() : base("ContractorEntity", WHMS.EntityType.ContractorEntity, false) { }
		
		/// <summary>Creates a new ContractorEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new ContractorEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewContractorUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty CurrencyEntity objects.</summary>
	[Serializable]
	public partial class CurrencyEntityFactory : EntityFactoryBase2<CurrencyEntity> {
		/// <summary>CTor</summary>
		public CurrencyEntityFactory() : base("CurrencyEntity", WHMS.EntityType.CurrencyEntity, false) { }
		
		/// <summary>Creates a new CurrencyEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new CurrencyEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewCurrencyUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty DepositTransactionEntity objects.</summary>
	[Serializable]
	public partial class DepositTransactionEntityFactory : EntityFactoryBase2<DepositTransactionEntity> {
		/// <summary>CTor</summary>
		public DepositTransactionEntityFactory() : base("DepositTransactionEntity", WHMS.EntityType.DepositTransactionEntity, false) { }
		
		/// <summary>Creates a new DepositTransactionEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new DepositTransactionEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewDepositTransactionUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty DepositTypeEntity objects.</summary>
	[Serializable]
	public partial class DepositTypeEntityFactory : EntityFactoryBase2<DepositTypeEntity> {
		/// <summary>CTor</summary>
		public DepositTypeEntityFactory() : base("DepositTypeEntity", WHMS.EntityType.DepositTypeEntity, false) { }
		
		/// <summary>Creates a new DepositTypeEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new DepositTypeEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewDepositTypeUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty InitialBalanceEntity objects.</summary>
	[Serializable]
	public partial class InitialBalanceEntityFactory : EntityFactoryBase2<InitialBalanceEntity> {
		/// <summary>CTor</summary>
		public InitialBalanceEntityFactory() : base("InitialBalanceEntity", WHMS.EntityType.InitialBalanceEntity, false) { }
		
		/// <summary>Creates a new InitialBalanceEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new InitialBalanceEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewInitialBalanceUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty InspectionTypeEntity objects.</summary>
	[Serializable]
	public partial class InspectionTypeEntityFactory : EntityFactoryBase2<InspectionTypeEntity> {
		/// <summary>CTor</summary>
		public InspectionTypeEntityFactory() : base("InspectionTypeEntity", WHMS.EntityType.InspectionTypeEntity, false) { }
		
		/// <summary>Creates a new InspectionTypeEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new InspectionTypeEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewInspectionTypeUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty InventoryEntity objects.</summary>
	[Serializable]
	public partial class InventoryEntityFactory : EntityFactoryBase2<InventoryEntity> {
		/// <summary>CTor</summary>
		public InventoryEntityFactory() : base("InventoryEntity", WHMS.EntityType.InventoryEntity, false) { }
		
		/// <summary>Creates a new InventoryEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new InventoryEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewInventoryUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty InventoryItemEntity objects.</summary>
	[Serializable]
	public partial class InventoryItemEntityFactory : EntityFactoryBase2<InventoryItemEntity> {
		/// <summary>CTor</summary>
		public InventoryItemEntityFactory() : base("InventoryItemEntity", WHMS.EntityType.InventoryItemEntity, false) { }
		
		/// <summary>Creates a new InventoryItemEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new InventoryItemEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewInventoryItemUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty ItemEntity objects.</summary>
	[Serializable]
	public partial class ItemEntityFactory : EntityFactoryBase2<ItemEntity> {
		/// <summary>CTor</summary>
		public ItemEntityFactory() : base("ItemEntity", WHMS.EntityType.ItemEntity, false) { }
		
		/// <summary>Creates a new ItemEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new ItemEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewItemUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty ItemSupplierEntity objects.</summary>
	[Serializable]
	public partial class ItemSupplierEntityFactory : EntityFactoryBase2<ItemSupplierEntity> {
		/// <summary>CTor</summary>
		public ItemSupplierEntityFactory() : base("ItemSupplierEntity", WHMS.EntityType.ItemSupplierEntity, false) { }
		
		/// <summary>Creates a new ItemSupplierEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new ItemSupplierEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewItemSupplierUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty ItemTypeEntity objects.</summary>
	[Serializable]
	public partial class ItemTypeEntityFactory : EntityFactoryBase2<ItemTypeEntity> {
		/// <summary>CTor</summary>
		public ItemTypeEntityFactory() : base("ItemTypeEntity", WHMS.EntityType.ItemTypeEntity, false) { }
		
		/// <summary>Creates a new ItemTypeEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new ItemTypeEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewItemTypeUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty ProjectEntity objects.</summary>
	[Serializable]
	public partial class ProjectEntityFactory : EntityFactoryBase2<ProjectEntity> {
		/// <summary>CTor</summary>
		public ProjectEntityFactory() : base("ProjectEntity", WHMS.EntityType.ProjectEntity, false) { }
		
		/// <summary>Creates a new ProjectEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new ProjectEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewProjectUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty ProjectContractorEntity objects.</summary>
	[Serializable]
	public partial class ProjectContractorEntityFactory : EntityFactoryBase2<ProjectContractorEntity> {
		/// <summary>CTor</summary>
		public ProjectContractorEntityFactory() : base("ProjectContractorEntity", WHMS.EntityType.ProjectContractorEntity, false) { }
		
		/// <summary>Creates a new ProjectContractorEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new ProjectContractorEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewProjectContractorUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty ProjectItemPlanEntity objects.</summary>
	[Serializable]
	public partial class ProjectItemPlanEntityFactory : EntityFactoryBase2<ProjectItemPlanEntity> {
		/// <summary>CTor</summary>
		public ProjectItemPlanEntityFactory() : base("ProjectItemPlanEntity", WHMS.EntityType.ProjectItemPlanEntity, false) { }
		
		/// <summary>Creates a new ProjectItemPlanEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new ProjectItemPlanEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewProjectItemPlanUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty RetrievalTransactionEntity objects.</summary>
	[Serializable]
	public partial class RetrievalTransactionEntityFactory : EntityFactoryBase2<RetrievalTransactionEntity> {
		/// <summary>CTor</summary>
		public RetrievalTransactionEntityFactory() : base("RetrievalTransactionEntity", WHMS.EntityType.RetrievalTransactionEntity, false) { }
		
		/// <summary>Creates a new RetrievalTransactionEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new RetrievalTransactionEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewRetrievalTransactionUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty RoleEntity objects.</summary>
	[Serializable]
	public partial class RoleEntityFactory : EntityFactoryBase2<RoleEntity> {
		/// <summary>CTor</summary>
		public RoleEntityFactory() : base("RoleEntity", WHMS.EntityType.RoleEntity, false) { }
		
		/// <summary>Creates a new RoleEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new RoleEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewRoleUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty ShelfEntity objects.</summary>
	[Serializable]
	public partial class ShelfEntityFactory : EntityFactoryBase2<ShelfEntity> {
		/// <summary>CTor</summary>
		public ShelfEntityFactory() : base("ShelfEntity", WHMS.EntityType.ShelfEntity, false) { }
		
		/// <summary>Creates a new ShelfEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new ShelfEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewShelfUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty ShelfTypeEntity objects.</summary>
	[Serializable]
	public partial class ShelfTypeEntityFactory : EntityFactoryBase2<ShelfTypeEntity> {
		/// <summary>CTor</summary>
		public ShelfTypeEntityFactory() : base("ShelfTypeEntity", WHMS.EntityType.ShelfTypeEntity, false) { }
		
		/// <summary>Creates a new ShelfTypeEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new ShelfTypeEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewShelfTypeUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty StoreEntity objects.</summary>
	[Serializable]
	public partial class StoreEntityFactory : EntityFactoryBase2<StoreEntity> {
		/// <summary>CTor</summary>
		public StoreEntityFactory() : base("StoreEntity", WHMS.EntityType.StoreEntity, false) { }
		
		/// <summary>Creates a new StoreEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new StoreEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewStoreUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty StorekeeperEntity objects.</summary>
	[Serializable]
	public partial class StorekeeperEntityFactory : EntityFactoryBase2<StorekeeperEntity> {
		/// <summary>CTor</summary>
		public StorekeeperEntityFactory() : base("StorekeeperEntity", WHMS.EntityType.StorekeeperEntity, false) { }
		
		/// <summary>Creates a new StorekeeperEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new StorekeeperEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewStorekeeperUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty StoreShelfBalanceEntity objects.</summary>
	[Serializable]
	public partial class StoreShelfBalanceEntityFactory : EntityFactoryBase2<StoreShelfBalanceEntity> {
		/// <summary>CTor</summary>
		public StoreShelfBalanceEntityFactory() : base("StoreShelfBalanceEntity", WHMS.EntityType.StoreShelfBalanceEntity, false) { }
		
		/// <summary>Creates a new StoreShelfBalanceEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new StoreShelfBalanceEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewStoreShelfBalanceUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty SupplierEntity objects.</summary>
	[Serializable]
	public partial class SupplierEntityFactory : EntityFactoryBase2<SupplierEntity> {
		/// <summary>CTor</summary>
		public SupplierEntityFactory() : base("SupplierEntity", WHMS.EntityType.SupplierEntity, false) { }
		
		/// <summary>Creates a new SupplierEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new SupplierEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewSupplierUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty SupplyOrderEntity objects.</summary>
	[Serializable]
	public partial class SupplyOrderEntityFactory : EntityFactoryBase2<SupplyOrderEntity> {
		/// <summary>CTor</summary>
		public SupplyOrderEntityFactory() : base("SupplyOrderEntity", WHMS.EntityType.SupplyOrderEntity, false) { }
		
		/// <summary>Creates a new SupplyOrderEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new SupplyOrderEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewSupplyOrderUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty SupplyOrderItemEntity objects.</summary>
	[Serializable]
	public partial class SupplyOrderItemEntityFactory : EntityFactoryBase2<SupplyOrderItemEntity> {
		/// <summary>CTor</summary>
		public SupplyOrderItemEntityFactory() : base("SupplyOrderItemEntity", WHMS.EntityType.SupplyOrderItemEntity, false) { }
		
		/// <summary>Creates a new SupplyOrderItemEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new SupplyOrderItemEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewSupplyOrderItemUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty TransactionEntity objects.</summary>
	[Serializable]
	public partial class TransactionEntityFactory : EntityFactoryBase2<TransactionEntity> {
		/// <summary>CTor</summary>
		public TransactionEntityFactory() : base("TransactionEntity", WHMS.EntityType.TransactionEntity, false) { }
		
		/// <summary>Creates a new TransactionEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new TransactionEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewTransactionUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty TransactionItemEntity objects.</summary>
	[Serializable]
	public partial class TransactionItemEntityFactory : EntityFactoryBase2<TransactionItemEntity> {
		/// <summary>CTor</summary>
		public TransactionItemEntityFactory() : base("TransactionItemEntity", WHMS.EntityType.TransactionItemEntity, false) { }
		
		/// <summary>Creates a new TransactionItemEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new TransactionItemEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewTransactionItemUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty TransferRequestEntity objects.</summary>
	[Serializable]
	public partial class TransferRequestEntityFactory : EntityFactoryBase2<TransferRequestEntity> {
		/// <summary>CTor</summary>
		public TransferRequestEntityFactory() : base("TransferRequestEntity", WHMS.EntityType.TransferRequestEntity, false) { }
		
		/// <summary>Creates a new TransferRequestEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new TransferRequestEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewTransferRequestUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty TransferRequestItemEntity objects.</summary>
	[Serializable]
	public partial class TransferRequestItemEntityFactory : EntityFactoryBase2<TransferRequestItemEntity> {
		/// <summary>CTor</summary>
		public TransferRequestItemEntityFactory() : base("TransferRequestItemEntity", WHMS.EntityType.TransferRequestItemEntity, false) { }
		
		/// <summary>Creates a new TransferRequestItemEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new TransferRequestItemEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewTransferRequestItemUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty TransferTransactionEntity objects.</summary>
	[Serializable]
	public partial class TransferTransactionEntityFactory : EntityFactoryBase2<TransferTransactionEntity> {
		/// <summary>CTor</summary>
		public TransferTransactionEntityFactory() : base("TransferTransactionEntity", WHMS.EntityType.TransferTransactionEntity, false) { }
		
		/// <summary>Creates a new TransferTransactionEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new TransferTransactionEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewTransferTransactionUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty UnitEntity objects.</summary>
	[Serializable]
	public partial class UnitEntityFactory : EntityFactoryBase2<UnitEntity> {
		/// <summary>CTor</summary>
		public UnitEntityFactory() : base("UnitEntity", WHMS.EntityType.UnitEntity, false) { }
		
		/// <summary>Creates a new UnitEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new UnitEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewUnitUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty UnitConverterEntity objects.</summary>
	[Serializable]
	public partial class UnitConverterEntityFactory : EntityFactoryBase2<UnitConverterEntity> {
		/// <summary>CTor</summary>
		public UnitConverterEntityFactory() : base("UnitConverterEntity", WHMS.EntityType.UnitConverterEntity, false) { }
		
		/// <summary>Creates a new UnitConverterEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new UnitConverterEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewUnitConverterUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty UnitTypeEntity objects.</summary>
	[Serializable]
	public partial class UnitTypeEntityFactory : EntityFactoryBase2<UnitTypeEntity> {
		/// <summary>CTor</summary>
		public UnitTypeEntityFactory() : base("UnitTypeEntity", WHMS.EntityType.UnitTypeEntity, false) { }
		
		/// <summary>Creates a new UnitTypeEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new UnitTypeEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewUnitTypeUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty UserEntity objects.</summary>
	[Serializable]
	public partial class UserEntityFactory : EntityFactoryBase2<UserEntity> {
		/// <summary>CTor</summary>
		public UserEntityFactory() : base("UserEntity", WHMS.EntityType.UserEntity, false) { }
		
		/// <summary>Creates a new UserEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new UserEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewUserUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty UserRoleEntity objects.</summary>
	[Serializable]
	public partial class UserRoleEntityFactory : EntityFactoryBase2<UserRoleEntity> {
		/// <summary>CTor</summary>
		public UserRoleEntityFactory() : base("UserRoleEntity", WHMS.EntityType.UserRoleEntity, false) { }
		
		/// <summary>Creates a new UserRoleEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new UserRoleEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewUserRoleUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty WithdrawalTypeEntity objects.</summary>
	[Serializable]
	public partial class WithdrawalTypeEntityFactory : EntityFactoryBase2<WithdrawalTypeEntity> {
		/// <summary>CTor</summary>
		public WithdrawalTypeEntityFactory() : base("WithdrawalTypeEntity", WHMS.EntityType.WithdrawalTypeEntity, false) { }
		
		/// <summary>Creates a new WithdrawalTypeEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new WithdrawalTypeEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewWithdrawalTypeUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty WithdrawRequestEntity objects.</summary>
	[Serializable]
	public partial class WithdrawRequestEntityFactory : EntityFactoryBase2<WithdrawRequestEntity> {
		/// <summary>CTor</summary>
		public WithdrawRequestEntityFactory() : base("WithdrawRequestEntity", WHMS.EntityType.WithdrawRequestEntity, false) { }
		
		/// <summary>Creates a new WithdrawRequestEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new WithdrawRequestEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewWithdrawRequestUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty WithdrawRequestItemEntity objects.</summary>
	[Serializable]
	public partial class WithdrawRequestItemEntityFactory : EntityFactoryBase2<WithdrawRequestItemEntity> {
		/// <summary>CTor</summary>
		public WithdrawRequestItemEntityFactory() : base("WithdrawRequestItemEntity", WHMS.EntityType.WithdrawRequestItemEntity, false) { }
		
		/// <summary>Creates a new WithdrawRequestItemEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new WithdrawRequestItemEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewWithdrawRequestItemUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty WithdrawTransactionEntity objects.</summary>
	[Serializable]
	public partial class WithdrawTransactionEntityFactory : EntityFactoryBase2<WithdrawTransactionEntity> {
		/// <summary>CTor</summary>
		public WithdrawTransactionEntityFactory() : base("WithdrawTransactionEntity", WHMS.EntityType.WithdrawTransactionEntity, false) { }
		
		/// <summary>Creates a new WithdrawTransactionEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new WithdrawTransactionEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewWithdrawTransactionUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty WithdrawzPartyEntity objects.</summary>
	[Serializable]
	public partial class WithdrawzPartyEntityFactory : EntityFactoryBase2<WithdrawzPartyEntity> {
		/// <summary>CTor</summary>
		public WithdrawzPartyEntityFactory() : base("WithdrawzPartyEntity", WHMS.EntityType.WithdrawzPartyEntity, false) { }
		
		/// <summary>Creates a new WithdrawzPartyEntity instance but uses a special constructor which will set the Fields object of the new IEntity2 instance to the passed in fields object.</summary>
		/// <param name="fields">Populated IEntityFields2 object for the new IEntity2 to create</param>
		/// <returns>Fully created and populated (due to the IEntityFields2 object) IEntity2 object</returns>
		public override IEntity2 Create(IEntityFields2 fields) {
			IEntity2 toReturn = new WithdrawzPartyEntity(fields);
			// __LLBLGENPRO_USER_CODE_REGION_START CreateNewWithdrawzPartyUsingFields
			// __LLBLGENPRO_USER_CODE_REGION_END
			return toReturn;
		}
		#region Included Code

		#endregion
	}

	/// <summary>Factory to create new, empty Entity objects based on the entity type specified. Uses  entity specific factory objects</summary>
	[Serializable]
	public partial class GeneralEntityFactory
	{
		/// <summary>Creates a new, empty Entity object of the type specified</summary>
		/// <param name="entityTypeToCreate">The entity type to create.</param>
		/// <returns>A new, empty Entity object.</returns>
		public static IEntity2 Create(WHMS.EntityType entityTypeToCreate)
		{
			IEntityFactory2 factoryToUse = null;
			switch(entityTypeToCreate)
			{
				case WHMS.EntityType.ContractorEntity:
					factoryToUse = new ContractorEntityFactory();
					break;
				case WHMS.EntityType.CurrencyEntity:
					factoryToUse = new CurrencyEntityFactory();
					break;
				case WHMS.EntityType.DepositTransactionEntity:
					factoryToUse = new DepositTransactionEntityFactory();
					break;
				case WHMS.EntityType.DepositTypeEntity:
					factoryToUse = new DepositTypeEntityFactory();
					break;
				case WHMS.EntityType.InitialBalanceEntity:
					factoryToUse = new InitialBalanceEntityFactory();
					break;
				case WHMS.EntityType.InspectionTypeEntity:
					factoryToUse = new InspectionTypeEntityFactory();
					break;
				case WHMS.EntityType.InventoryEntity:
					factoryToUse = new InventoryEntityFactory();
					break;
				case WHMS.EntityType.InventoryItemEntity:
					factoryToUse = new InventoryItemEntityFactory();
					break;
				case WHMS.EntityType.ItemEntity:
					factoryToUse = new ItemEntityFactory();
					break;
				case WHMS.EntityType.ItemSupplierEntity:
					factoryToUse = new ItemSupplierEntityFactory();
					break;
				case WHMS.EntityType.ItemTypeEntity:
					factoryToUse = new ItemTypeEntityFactory();
					break;
				case WHMS.EntityType.ProjectEntity:
					factoryToUse = new ProjectEntityFactory();
					break;
				case WHMS.EntityType.ProjectContractorEntity:
					factoryToUse = new ProjectContractorEntityFactory();
					break;
				case WHMS.EntityType.ProjectItemPlanEntity:
					factoryToUse = new ProjectItemPlanEntityFactory();
					break;
				case WHMS.EntityType.RetrievalTransactionEntity:
					factoryToUse = new RetrievalTransactionEntityFactory();
					break;
				case WHMS.EntityType.RoleEntity:
					factoryToUse = new RoleEntityFactory();
					break;
				case WHMS.EntityType.ShelfEntity:
					factoryToUse = new ShelfEntityFactory();
					break;
				case WHMS.EntityType.ShelfTypeEntity:
					factoryToUse = new ShelfTypeEntityFactory();
					break;
				case WHMS.EntityType.StoreEntity:
					factoryToUse = new StoreEntityFactory();
					break;
				case WHMS.EntityType.StorekeeperEntity:
					factoryToUse = new StorekeeperEntityFactory();
					break;
				case WHMS.EntityType.StoreShelfBalanceEntity:
					factoryToUse = new StoreShelfBalanceEntityFactory();
					break;
				case WHMS.EntityType.SupplierEntity:
					factoryToUse = new SupplierEntityFactory();
					break;
				case WHMS.EntityType.SupplyOrderEntity:
					factoryToUse = new SupplyOrderEntityFactory();
					break;
				case WHMS.EntityType.SupplyOrderItemEntity:
					factoryToUse = new SupplyOrderItemEntityFactory();
					break;
				case WHMS.EntityType.TransactionEntity:
					factoryToUse = new TransactionEntityFactory();
					break;
				case WHMS.EntityType.TransactionItemEntity:
					factoryToUse = new TransactionItemEntityFactory();
					break;
				case WHMS.EntityType.TransferRequestEntity:
					factoryToUse = new TransferRequestEntityFactory();
					break;
				case WHMS.EntityType.TransferRequestItemEntity:
					factoryToUse = new TransferRequestItemEntityFactory();
					break;
				case WHMS.EntityType.TransferTransactionEntity:
					factoryToUse = new TransferTransactionEntityFactory();
					break;
				case WHMS.EntityType.UnitEntity:
					factoryToUse = new UnitEntityFactory();
					break;
				case WHMS.EntityType.UnitConverterEntity:
					factoryToUse = new UnitConverterEntityFactory();
					break;
				case WHMS.EntityType.UnitTypeEntity:
					factoryToUse = new UnitTypeEntityFactory();
					break;
				case WHMS.EntityType.UserEntity:
					factoryToUse = new UserEntityFactory();
					break;
				case WHMS.EntityType.UserRoleEntity:
					factoryToUse = new UserRoleEntityFactory();
					break;
				case WHMS.EntityType.WithdrawalTypeEntity:
					factoryToUse = new WithdrawalTypeEntityFactory();
					break;
				case WHMS.EntityType.WithdrawRequestEntity:
					factoryToUse = new WithdrawRequestEntityFactory();
					break;
				case WHMS.EntityType.WithdrawRequestItemEntity:
					factoryToUse = new WithdrawRequestItemEntityFactory();
					break;
				case WHMS.EntityType.WithdrawTransactionEntity:
					factoryToUse = new WithdrawTransactionEntityFactory();
					break;
				case WHMS.EntityType.WithdrawzPartyEntity:
					factoryToUse = new WithdrawzPartyEntityFactory();
					break;
			}
			IEntity2 toReturn = null;
			if(factoryToUse != null)
			{
				toReturn = factoryToUse.Create();
			}
			return toReturn;
		}		
	}
		
	/// <summary>Class which is used to obtain the entity factory based on the .NET type of the entity. </summary>
	[Serializable]
	public static class EntityFactoryFactory
	{
#if CF
		/// <summary>Gets the factory of the entity with the WHMS.EntityType specified</summary>
		/// <param name="typeOfEntity">The type of entity.</param>
		/// <returns>factory to use or null if not found</returns>
		public static IEntityFactory2 GetFactory(WHMS.EntityType typeOfEntity)
		{
			return GeneralEntityFactory.Create(typeOfEntity).GetEntityFactory();
		}
#else
		private static Dictionary<Type, IEntityFactory2> _factoryPerType = new Dictionary<Type, IEntityFactory2>();

		/// <summary>Initializes the <see cref="EntityFactoryFactory"/> class.</summary>
		static EntityFactoryFactory()
		{
			Array entityTypeValues = Enum.GetValues(typeof(WHMS.EntityType));
			foreach(int entityTypeValue in entityTypeValues)
			{
				IEntity2 dummy = GeneralEntityFactory.Create((WHMS.EntityType)entityTypeValue);
				_factoryPerType.Add(dummy.GetType(), dummy.GetEntityFactory());
			}
		}

		/// <summary>Gets the factory of the entity with the .NET type specified</summary>
		/// <param name="typeOfEntity">The type of entity.</param>
		/// <returns>factory to use or null if not found</returns>
		public static IEntityFactory2 GetFactory(Type typeOfEntity)
		{
			IEntityFactory2 toReturn = null;
			_factoryPerType.TryGetValue(typeOfEntity, out toReturn);
			return toReturn;
		}

		/// <summary>Gets the factory of the entity with the WHMS.EntityType specified</summary>
		/// <param name="typeOfEntity">The type of entity.</param>
		/// <returns>factory to use or null if not found</returns>
		public static IEntityFactory2 GetFactory(WHMS.EntityType typeOfEntity)
		{
			return GetFactory(GeneralEntityFactory.Create(typeOfEntity).GetType());
		}
#endif		
	}
		
	/// <summary>Element creator for creating project elements from somewhere else, like inside Linq providers.</summary>
	public class ElementCreator : ElementCreatorBase, IElementCreator2
	{
		/// <summary>Gets the factory of the Entity type with the WHMS.EntityType value passed in</summary>
		/// <param name="entityTypeValue">The entity type value.</param>
		/// <returns>the entity factory of the entity type or null if not found</returns>
		public IEntityFactory2 GetFactory(int entityTypeValue)
		{
			return (IEntityFactory2)this.GetFactoryImpl(entityTypeValue);
		}
		
		/// <summary>Gets the factory of the Entity type with the .NET type passed in</summary>
		/// <param name="typeOfEntity">The type of entity.</param>
		/// <returns>the entity factory of the entity type or null if not found</returns>
		public IEntityFactory2 GetFactory(Type typeOfEntity)
		{
			return (IEntityFactory2)this.GetFactoryImpl(typeOfEntity);
		}

		/// <summary>Creates a new resultset fields object with the number of field slots reserved as specified</summary>
		/// <param name="numberOfFields">The number of fields.</param>
		/// <returns>ready to use resultsetfields object</returns>
		public IEntityFields2 CreateResultsetFields(int numberOfFields)
		{
			return new ResultsetFields(numberOfFields);
		}

		/// <summary>Creates a new dynamic relation instance</summary>
		/// <param name="leftOperand">The left operand.</param>
		/// <returns>ready to use dynamic relation</returns>
		public override IDynamicRelation CreateDynamicRelation(DerivedTableDefinition leftOperand)
		{
			return new DynamicRelation(leftOperand);
		}

		/// <summary>Creates a new dynamic relation instance</summary>
		/// <param name="leftOperand">The left operand.</param>
		/// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param>
		/// <param name="rightOperand">The right operand.</param>
		/// <param name="onClause">The on clause for the join.</param>
		/// <returns>ready to use dynamic relation</returns>
		public override IDynamicRelation CreateDynamicRelation(DerivedTableDefinition leftOperand, JoinHint joinType, DerivedTableDefinition rightOperand, IPredicate onClause)
		{
			return new DynamicRelation(leftOperand, joinType, rightOperand, onClause);
		}

		/// <summary>Creates a new dynamic relation instance</summary>
		/// <param name="leftOperand">The left operand.</param>
		/// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param>
		/// <param name="rightOperandEntityName">Name of the entity, which is used as the right operand.</param>
		/// <param name="aliasRightOperand">The alias of the right operand. If you don't want to / need to alias the right operand (only alias if you have to), specify string.Empty.</param>
		/// <param name="onClause">The on clause for the join.</param>
		/// <returns>ready to use dynamic relation</returns>
		public override IDynamicRelation CreateDynamicRelation(DerivedTableDefinition leftOperand, JoinHint joinType, string rightOperandEntityName, string aliasRightOperand, IPredicate onClause)
		{
			return new DynamicRelation(leftOperand, joinType, (WHMS.EntityType)Enum.Parse(typeof(WHMS.EntityType), rightOperandEntityName, false), aliasRightOperand, onClause);
		}

		/// <summary>Creates a new dynamic relation instance</summary>
		/// <param name="leftOperandEntityName">Name of the entity which is used as the left operand.</param>
		/// <param name="joinType">Type of the join. If None is specified, Inner is assumed.</param>
		/// <param name="rightOperandEntityName">Name of the entity, which is used as the right operand.</param>
		/// <param name="aliasLeftOperand">The alias of the left operand. If you don't want to / need to alias the right operand (only alias if you have to), specify string.Empty.</param>
		/// <param name="aliasRightOperand">The alias of the right operand. If you don't want to / need to alias the right operand (only alias if you have to), specify string.Empty.</param>
		/// <param name="onClause">The on clause for the join.</param>
		/// <returns>ready to use dynamic relation</returns>
		public override IDynamicRelation CreateDynamicRelation(string leftOperandEntityName, JoinHint joinType, string rightOperandEntityName, string aliasLeftOperand, string aliasRightOperand, IPredicate onClause)
		{
			return new DynamicRelation((WHMS.EntityType)Enum.Parse(typeof(WHMS.EntityType), leftOperandEntityName, false), joinType, (WHMS.EntityType)Enum.Parse(typeof(WHMS.EntityType), rightOperandEntityName, false), aliasLeftOperand, aliasRightOperand, onClause);
		}
		
		/// <summary>Obtains the inheritance info provider instance from the singleton </summary>
		/// <returns>The singleton instance of the inheritance info provider</returns>
		public override IInheritanceInfoProvider ObtainInheritanceInfoProviderInstance()
		{
			return InheritanceInfoProviderSingleton.GetInstance();
		}
		
		/// <summary>Implementation of the routine which gets the factory of the Entity type with the WHMS.EntityType value passed in</summary>
		/// <param name="entityTypeValue">The entity type value.</param>
		/// <returns>the entity factory of the entity type or null if not found</returns>
		protected override IEntityFactoryCore GetFactoryImpl(int entityTypeValue)
		{
			return EntityFactoryFactory.GetFactory((WHMS.EntityType)entityTypeValue);
		}
#if !CF		
		/// <summary>Implementation of the routine which gets the factory of the Entity type with the .NET type passed in</summary>
		/// <param name="typeOfEntity">The type of entity.</param>
		/// <returns>the entity factory of the entity type or null if not found</returns>
		protected override IEntityFactoryCore GetFactoryImpl(Type typeOfEntity)
		{
			return EntityFactoryFactory.GetFactory(typeOfEntity);
		}
#endif
	}
}
